#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;

int n, m;
LL f[N];

LL find(int l, int r)
{
    return f[r] - f[l - 1];
}

int main()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i ++)
    {
        int x; cin >> x;
        f[i] = f[i - 1] + x;
    }
    while(m --)
    {
        int l, r; cin >> l >> r;
        cout << find(l, r) << endl;
    }
    return 0;
}